﻿using System;
using System.Configuration;

namespace Yz.Base
{
    public class BaseConfig
    {
        /// <summary>
        /// 平台名称
        /// </summary>
        public static string SysName { get; } = ConfigurationManager.AppSettings["SysName"];
        /// <summary>
        /// 版本号防止js，css缓存
        /// </summary>
        public static string YzVersion => ConfigurationManager.AppSettings["YzVersion"];
        /// <summary>
        /// 接口误差时间
        /// </summary>
        public static int TokenTime => Convert.ToInt32(ConfigurationManager.AppSettings["TokenTime"]);
        /// <summary>
        /// 应用ID
        /// </summary>
        public static string AppId => ConfigurationManager.AppSettings["AppId"];
        /// <summary>
        /// 应用秘钥
        /// </summary>
        public static string AppSecret => ConfigurationManager.AppSettings["AppSecret"];
        /// <summary>
        /// 是否启用EF更新表结构
        /// </summary>
        public static bool EFMigration => ConfigurationManager.AppSettings["EFMigration"] == "1";
        /// <summary>
        /// jwt认证秘钥
        /// </summary>
        public static string JwtSecretKey => ConfigurationManager.AppSettings["JwtSecretKey"];

        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static string YzConnStr { get; } = ConfigurationManager.ConnectionStrings["YzContext"].ConnectionString;

        /// <summary>
        /// token有效时间（分钟）
        /// </summary>
        public static int UnifyTokenTime { get; } = Convert.ToInt32(ConfigurationManager.AppSettings["UnifyTokenTime"]);
        /// <summary>
        /// 剩余时间（低于此时间刷新缓存）（分钟）
        /// </summary>
        public static int TokenSurplusTime { get; } = Convert.ToInt32(ConfigurationManager.AppSettings["TokenSurplusTime"]);
        /// <summary>
        /// 最大登录尝试次数
        /// </summary>
        public static int LoginFailMaxNum { get; } = Convert.ToInt32(ConfigurationManager.AppSettings["LoginFailMaxNum"]);
        /// <summary>
        /// 登录失败锁定时间（分钟）
        /// </summary>
        public static int LoginLockTime { get; } = Convert.ToInt32(ConfigurationManager.AppSettings["LoginLockTime"]);
        /// <summary>
        /// EF执行最大时间（超过此时间记录下sql语句）
        /// </summary>
        public static int EFMaxTime { get; } = Convert.ToInt32(ConfigurationManager.AppSettings["EFMaxTime"]);
        /// <summary>
        /// 记录EF语句
        /// </summary>
        public static bool EnableEFLog => ConfigurationManager.AppSettings["EnableEFLog"] == "1";
        /// <summary>
        /// 是否启动调试日志记录
        /// </summary>
        public static bool EnableDebugLog => ConfigurationManager.AppSettings["EnableDebugLog"] == "1";
        /// <summary>
        /// 是否启动信息记录日志
        /// </summary>
        public static bool EnableInfoLog => ConfigurationManager.AppSettings["EnableInfoLog"] == "1";
    }
}
